﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentNHibernate.Mapping;
using YasharEl.Infrastructure.Core.EntityModel.Prototype;
using YasharEl.Infrastructure.Core.Locations;

namespace YasharEl.Infrastructure.Core.PersistenceModel.NHibernate.Prototype.Mappings
{
    public class PropertyInstanceAddressValueEntityMap : ClassMap<PropertyInstanceAddressValueEntity>
    {
        public PropertyInstanceAddressValueEntityMap()
        {
            // the name of the table corresonding to the data type
            Table("PropertyInstanceAddressValues");

            Id(e => e.Id)
                .Column("PropertyInstanceValueId")
                .GeneratedBy
                    .Identity();

            Component<Address>(e => e.RealValue,
                address =>
                {
                    address.Access.Property();
                    address.Map(a => a.City)
                        .Column("City")
                        .Not.Nullable()
                        .Length(100);
                    address.Map(a => a.Street)
                        .Column("Street")
                        .Nullable()
                        .Length(100);
                    address.Map(a => a.ZipCode)
                        .Column("ZipCode")
                        .Nullable();
                    address.Map(a => a.HouseNumber)
                        .Column("HouseNumber")
                        .Nullable();
                    address.Map(a => a.ApartmentNumber)
                        .Column("ApartmentNumber")
                        .Nullable();
                    address.Map(a => a.POBox)
                        .Column("POBox")
                        .Nullable();
                    address.Map(a => a.Entrance)
                        .Column("Entrance")
                        .Nullable()
                        .Length(6);
                }
            );
        }
    }
}
